home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / forth / pfe-0.000 / pfe-0 / pfe-0.9.13 / src / compiler.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-17  |  5.1 KB  |  172 lines

  1. /*
  2.  * This file is part of the portable Forth environment written in ANSI C.
  3.  * Copyright (C) 1995  Dirk Uwe Zoller
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Library General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13.  * See the GNU Library General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Library General Public
  16.  * License along with this library; if not, write to the Free
  17.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  * This file is version 0.9.13 of 17-July-95
  20.  * Check for the latest version of this package via anonymous ftp at
  21.  *    roxi.rz.fht-mannheim.de:/pub/languages/forth/pfe-VERSION.tar.gz
  22.  * or    sunsite.unc.edu:/pub/languages/forth/pfe-VERSION.tar.gz
  23.  * or    ftp.cygnus.com:/pub/forth/pfe-VERSION.tar.gz
  24.  *
  25.  * Please direct any comments via internet to
  26.  *    duz@roxi.rz.fht-mannheim.de.
  27.  * Thank You.
  28.  */
  29. /*
  30.  * compiler.h ---    lists of declarations reflecting internal structures
  31.  *            of pfe mainly for decompiler (SEE) and debugger.
  32.  * (duz 23Aug93)
  33.  */
  34.  
  35. #ifndef __COMPILER_H
  36. #define __COMPILER_H
  37.  
  38. typedef struct Decomp Decomp;    /* informations for the decompiler */
  39. typedef struct Semant Semant;    /* pointer set for state smart words */
  40. typedef struct Seman2 Seman2;    /* dito for even smarter words like TO */
  41.  
  42. enum                /* encodings for what information */
  43. {                /* follows the compiled word inline */
  44.   SKIPS_NOTHING,
  45.   SKIPS_OFFSET,
  46.   SKIPS_CELL,
  47.   SKIPS_DCELL,
  48.   SKIPS_FLOAT,
  49.   SKIPS_STRING,
  50.   SKIPS_2STRINGS
  51. };
  52.  
  53. typedef unsigned short ushrt;
  54.  
  55. struct Decomp            /* informations for the decompiler */
  56. {
  57.   unsigned skips:3;        /* this xt skips this many cells of data */
  58.   unsigned space:3;        /* additional spaces past the word */
  59.   unsigned cr_bef:1;        /* carriage return before printing */
  60.   signed ind_bef:4;        /* changed indentation before print */
  61.   unsigned cr_aft:1;        /* carriage return after print */
  62.   signed ind_aft:4;        /* changed indentation after print */
  63. };
  64.  
  65. struct Semant            /* for words with different compilation */
  66. {                /* and execution semantics: */
  67.   long magic;            /* mark begin of structure */
  68.   Decomp decomp;        /* decompiler aid */
  69.   char *name;            /* compiled by */
  70.   pCode comp;            /* compilation/interpretation semantics */
  71.   pCode exec[1];        /* execution semantics */
  72. };
  73.  
  74. struct Seman2            /* for words with different compilation */
  75. {                /* and two different execution semantics: */
  76.   long magic;            /* mark begin of structure */
  77.   Decomp decomp;        /* decompiler aid */
  78.   char *name;            /* compiled by */
  79.   pCode comp;            /* compilation/interpretation semantics */
  80.   pCode exec[2];        /* two different execution semantics */
  81. };                /* for cases like TO (value/local variable) */
  82.  
  83. #define COMPILES(C,E,S,STYLE)            \
  84. Semant APPEND (C,_semantics) =            \
  85. {                        \
  86.   SEMANT_MAGIC,                    \
  87.   { S, STYLE },                    \
  88.   NULL,                        \
  89.   APPEND (C,_),                    \
  90.   { APPEND (E,_) }                \
  91. }
  92.  
  93. #define COMPILES2(C,E1,E2,S,STYLE)        \
  94. Seman2 APPEND (C,_semantics) =            \
  95. {                        \
  96.   SEMANT_MAGIC,                    \
  97.   { S, STYLE },                    \
  98.   NULL,                        \
  99.   APPEND (C,_),                    \
  100.   { APPEND (E1,_), APPEND (E2,_) }        \
  101. }
  102.  
  103. /* compile execution semantics from within C-code: */
  104. #define COMPILE1(X)        COMMA (&APPEND(X,_semantics).exec [0])
  105. #define COMPILE2(X)        COMMA (&APPEND(X,_semantics).exec [1])
  106.  
  107. void compile1 (void);        /* compile execution semantics */
  108. void compile2 (void);        /* at system runtime */
  109.  
  110. Head *make_head (const char *name, int count, char **nfa, Wordl * wid);
  111. Semant *to_semant (Xt xt);
  112. char category (pCode p);
  113. void decompile (char *nfa, Xt xt);
  114.  
  115. code (noop);
  116. code (ahead);
  117.  
  118. code (backward_mark);        /* FORTH-83 style system extension words */
  119. code (backward_resolve);
  120. code (forward_mark);
  121. code (forward_resolve);
  122. code (bracket_compile);
  123.  
  124. code (smudge);
  125. code (unsmudge);
  126.  
  127. /* Local variables: */
  128.  
  129. int find_local (char *nm, int l);
  130. int compile_local (char *name, int len);
  131.  
  132. /* Runtimes to identify words by them: */
  133.  
  134. code (to_execution);
  135. code (plus_to_execution);
  136. code (locals_bar_execution);
  137. code (locals_exit_execution);
  138. code (local_execution);
  139. code (to_local_execution);
  140. code (plus_to_local_execution);
  141.  
  142. code (semicolon_execution);
  143. code (literal_execution);
  144. code (two_literal_execution);
  145. code (f_literal_execution);
  146.  
  147. void create_runtime (void);
  148. void constant_runtime (void);
  149. void value_runtime (void);
  150. void two_constant_runtime (void);
  151. void f_constant_runtime (void);
  152. void f_variable_runtime (void);
  153. void colon_runtime (void);
  154. void debug_colon_runtime (void);
  155. void sysvar_runtime (void);
  156. void sysconst_runtime (void);
  157. void dictvar_runtime (void);
  158. void dictconst_runtime (void);
  159.  
  160. void only_runtime (void);
  161. void vocabulary_runtime (void);
  162. void does_defined_runtime (void);
  163. void debug_does_defined_runtime (void);
  164. void marker_runtime (void);
  165.  
  166. extern Semant literal_semantics;
  167. extern Semant two_literal_semantics;
  168. extern Seman2 f_literal_semantics;
  169. extern Seman2 semicolon_semantics;
  170.  
  171. #endif
  172.